package com.youlu.campus.entity.douyin;

import com.youlu.campus.base.user.UserBase;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.mongodb.core.index.IndexDirection;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Date;
import java.util.Set;

/**
 * @author : [dengbo]
 * @className : DouYinMiniUserPO
 * @description : [抖音用户表]
 * @createTime : [2023/2/28 14:23]
 */
@Getter
@Setter
@Document("douyin_mini_user_info")
public class DouYinMiniUserPO extends UserBase {
    /**
     * 账户ID
     */
    @Indexed
    private String accountInfoId;
    /**
     * 老账号ID
     */
    private String oldAccountInfoId;
    /**
     * 会员卡编号
     */
    @Indexed
    private String memberShipInfoId;

    /**
     * 是否会员.是否会员
     */
    private Boolean memberShiped;
    /**
     * 是否失效
     */
    private Date expiredTime;
    /**
     * 剩余次数
     */
    private Integer remainedNum;
    /**
     * 是否授权
     */
    private Boolean binded = Boolean.FALSE;

    /**
     * 是否绑定手机号
     */
    protected Boolean checkedMobile;
    /**
     * 绑定手机号时间
     */
    @Indexed(direction = IndexDirection.DESCENDING)
    protected Date checkedMobileTime;
    /**
     * 排行榜头像
     */
    protected String rankAvatarUrl;
    /**
     * 排行榜昵称
     */
    protected String rankNickName;

    /**
     * 有效头像
     */
    private Boolean validLogo = Boolean.TRUE;

    /**
     * 账户列表ID
     */
    private Set<String> accountInfoIdList;

    public void checkNickNameAndAvatarUrl(){
        if(StringUtils.isAnyBlank(this.unionId,this.nickName,this.avatarUrl)){
            this.binded = Boolean.FALSE;
        }else{
            //已授权
            this.binded =Boolean.TRUE;
        }

    }

}
